package org.darkforest.merchant.controller;

import net.sf.json.JSONObject;
import org.darkforest.common.services.EvaluateService;
import org.darkforest.model.EvaluateGoods;
import org.darkforest.model.EvaluateGoodsSearchBean;
import org.darkforest.vo.StoreSellerVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;

/**
 * Created by chenyu on 15/1/30.
 * 订单物流相关控制类
 */
@Controller
@RequestMapping(value="/evaluate")
public class EvaluateController {

    @Autowired
    private EvaluateService evaluateService;
    /**
     * 订单列表
     * @param request
     * @return
     */
    @RequestMapping(value = "evaluateList")
    public ModelAndView orderList(HttpServletRequest request,EvaluateGoodsSearchBean page) {
        Integer storeId = ((StoreSellerVo) request.getSession().getAttribute("sellerInfo")).getStoreId();
        page.setStoreId(storeId);
        evaluateService.evaluateList(page);
        return new ModelAndView("evaluate/evaluateList", "page", page);
    }


    @RequestMapping(value = "updateExplain")
    public void  updateExplain(HttpServletResponse response ,EvaluateGoods evaluate) throws Exception{
        evaluateService.updateEvaluate(evaluate);
        JSONObject json = new JSONObject();
        json.put("result",true);
        PrintWriter out = response.getWriter();
        out.write(json.toString());
       // return new ModelAndView("order/orderDetail");
    }
}
